package com.study.hot.rx.views

import com.chad.library.adapter.base.BaseSectionQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.chad.library.adapter.base.entity.SectionEntity
import com.study.hot.R
import com.study.hot.model.Product

/**
 * <pre>
 *     author : fauks
 *     time   : 2020/03/28
 *     desc   :
 * </pre>
 */
class ProductAdapter(layoutResId: Int, sectionHeadResId: Int, data: MutableList<ProductSection>)
    : BaseSectionQuickAdapter<ProductAdapter.ProductSection, BaseViewHolder>(layoutResId, sectionHeadResId, data) {

    class ProductSection : SectionEntity<Product> {
        constructor(isHeader: Boolean, header: String?) : super(isHeader, header)
        constructor(product: Product) : super(product)
    }

    override fun convertHead(helper: BaseViewHolder, item: ProductSection) {
        helper.setText(R.id.categoryNameTv, item.header)
    }

    override fun convert(helper: BaseViewHolder, item: ProductSection) {
        helper.setText(R.id.productNameTv, item.t.name)
    }
}